﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using RayD.Core;
using RayD.Repository.Entites.SystemModule;
using RayD.App.SystemModule;
using RayD.WebApi.Models;
using RayD.Repository;

namespace RayD.WebApi.Controllers.Admin
{
    /// <summary>
    /// 数据表资源
    /// </summary>
    public class DatabaseTableController : BaseAdminController
    {
        #region 构造函数注入

        private DatabaseTableApp _databaseTableService;
        public DatabaseTableController(DatabaseTableApp databaseTableService)
        {
            this._databaseTableService = databaseTableService;
        }
        #endregion

        #region 参数实体
        #endregion

        #region 获取数据

        /// <summary>
        /// 获取当前数据库数据表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResParameter<IEnumerable<DatabaseTableModel>> GetList()
        {
            var list = _databaseTableService.GetTableList();
            return Success(list);
        }

        /// <summary>
        /// 获取当前数据库数据表的字段数据
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <returns></returns>
        [HttpGet]
        public ResParameter<IEnumerable<DatabaseTableFieldModel>> GetFieldList(string tableName)
        {
            var list = _databaseTableService.GetTableFiledList(tableName);
            return Success(list);
        }
        #endregion

        #region 提交数据

        #endregion
    }

}
